home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieFilmtipset.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  151 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id$'
  4.  
  5. # Copyright (c) 2007
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27. import re
  28.  
  29. plugin_name = "Filmtipset.se"
  30. plugin_description = "Filmtipset.se"
  31. plugin_url = "www.filmtipset.se"
  32. plugin_language = _("Swedish")
  33. plugin_author = "Michael Jahn"
  34. plugin_author_email = "<mikej06@hotmail.com>"
  35. plugin_version = "1.1"
  36.  
  37. class Plugin(movie.Movie):
  38.  
  39.     def __init__(self, id):
  40.         self.encode='iso-8859-1'
  41.         self.movie_id = id
  42.         self.url = 'http://www.filmtipset.se/film/' + str(self.movie_id)
  43.  
  44.     def get_image(self):
  45.         self.image_url = ''
  46.         tmp = gutils.trim(self.page, 'src="http://images.filmtipset.se/posters/', '"')
  47.         if tmp != '':
  48.             self.image_url = 'http://images.filmtipset.se/posters/' + tmp
  49.  
  50.     def get_o_title(self):
  51.         self.o_title = gutils.trim(self.page, 'Originaltitel:', '</tr>')
  52.         if self.o_title == '':
  53.             self.o_title = gutils.trim(self.page, '<h1>', '</h1>')
  54.  
  55.     def get_title(self):
  56.         self.title = gutils.trim(self.page, '<h1>', '</h1>')
  57.  
  58.     def get_director(self):
  59.         self.director = gutils.trim(self.page, 'Regissör:', '</tr>')
  60.  
  61.     def get_plot(self):
  62.         self.plot = self.regextrim(self.page, '<h2>Om [^>]*[>]', '</tr>')
  63.  
  64.     def get_year(self):
  65.         self.year = gutils.trim(self.page, 'Utgivningsår:', '</tr>')
  66.  
  67.     def get_runtime(self):
  68.         self.runtime = string.strip(gutils.trim(self.page, 'Längd:', ' min'))
  69.  
  70.     def get_genre(self):
  71.         self.genre = string.strip(gutils.trim(self.page, 'Nyckelord:', '</tr>'))
  72.         if self.genre == '':
  73.             self.genre = string.strip(gutils.trim(self.page, 'Genre:', '</tr>'))
  74.  
  75.     def get_cast(self):
  76.         self.cast = self.regextrim(self.page, 'Skådespelare [^:]*[:]', '</tr>')
  77.         self.cast = string.replace(self.cast, ', ', '\n')
  78.  
  79.     def get_classification(self):
  80.         self.classification = ''
  81.  
  82.     def get_studio(self):
  83.         self.studio = ''
  84.  
  85.     def get_o_site(self):
  86.         self.o_site = ''
  87.         tmp = gutils.trim(self.page, 'http://www.imdb.com', '"')
  88.         if tmp != '':
  89.             self.o_site = 'http://www.imdb.com' + tmp
  90.  
  91.     def get_site(self):
  92.         self.site = self.url
  93.  
  94.     def get_trailer(self):
  95.         self.trailer = ""
  96.  
  97.     def get_country(self):
  98.         self.country = string.strip(gutils.trim(self.page, 'Produktionsland:', '</span>'))
  99.  
  100.     def get_rating(self):
  101.         self.rating = "0"
  102.  
  103.     def get_notes(self):
  104.         self.notes = ''
  105.         tmp = gutils.trim(self.page, 'Alt. titel:', '</span>')
  106.         if tmp != '':
  107.             self.notes = self.notes + 'Alt. titel:' + string.strip(gutils.strip_tags(tmp))
  108.  
  109.     def regextrim(self,text,key1,key2):
  110.         obj = re.search(key1, text)
  111.         if obj is None:
  112.             return ''
  113.         else:
  114.             p1 = obj.end()
  115.         obj = re.search(key2, text[p1:])
  116.         if obj is None:
  117.             return ''
  118.         else:
  119.             p2 = p1 + obj.start()
  120.         return text[p1:p2]
  121.  
  122. class SearchPlugin(movie.SearchMovie):
  123.  
  124.     def __init__(self):
  125.         self.original_url_search   = "http://www.filmtipset.se/search.cgi?field=name&field=orgname&show_graded=1&search_value="
  126.         self.translated_url_search = "http://www.filmtipset.se/search.cgi?field=name&field=orgname&show_graded=1&search_value="
  127.         self.encode='iso-8859-1'
  128.  
  129.     def search(self,parent_window):
  130.         self.open_search(parent_window)
  131.         tmp_page = gutils.trim(self.page, 'Matchning', 'Hittade')
  132.         if tmp_page == '':
  133.             tmp_page = gutils.trim(self.page, 'Matchning', 'Visa fler')
  134.         self.page = tmp_page
  135.         return self.page
  136.  
  137.     def get_searches(self):
  138.         elements1 = re.split('href="film/', self.page)
  139.         elements1[0] = None
  140.         for element in elements1:
  141.             if element <> None:
  142.                 searchResult = re.search('["&?]', element)
  143.                 if searchResult is None:
  144.                     self.ids.append(gutils.before(element, '"'))
  145.                 else:
  146.                     self.ids.append(element[:searchResult.end() - 1])
  147.                 self.titles.append(
  148.                     gutils.strip_tags(gutils.trim(element, '>', '</a>')) + ' / ' +
  149.                     string.replace(gutils.trim(element, 'title="', '"'), ' ', ' ')
  150.                 )
  151.